﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Root="clr-namespace:Elysium.Theme">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium.Theme;component/Themes/SharedResources.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type TabControl}">

        <Setter Property="Background" Value="{StaticResource Transparent}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="FontFamily" Value="{x:Static Root:Parameters.FontFamily}"/>
        <Setter Property="FontSize" Value="{x:Static Root:Parameters.TextFontSize}"/>
        <Setter Property="FontWeight" Value="Normal"/>
        
        <Setter Property="ClipToBounds" Value="True"/>

        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Focusable" Value="False"/>

        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="0"/>

        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">

                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}"
                            TextBlock.FontFamily="{TemplateBinding FontFamily}"
                            TextBlock.FontSize="{TemplateBinding FontSize}"
                            TextBlock.FontWeight="{TemplateBinding FontWeight}"
                            KeyboardNavigation.DirectionalNavigation="Local"
                            ClipToBounds="{TemplateBinding ClipToBounds}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="FirstColumnDefinition"
                                                  Width="*"/>
                                <ColumnDefinition x:Name="SecondColumnDefinition"
                                                  Width="0"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="FirstRowDefinition"
                                               Height="Auto"/>
                                <RowDefinition x:Name="SecondRowDefinition"
                                               Height="*"/>
                            </Grid.RowDefinitions>
                            <Border x:Name="Border"
                                    Grid.Column="0"
                                    Grid.Row="0"
                                    Background="{StaticResource Transparent}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding Root:Parameters.TabControlIndicatorThickness}"/>
                            <TabPanel x:Name="HeaderPanel"
                                      Grid.Column="0"
                                      Grid.Row="0"
                                      Background="{StaticResource Transparent}"
                                      IsItemsHost="True"
                                      Grid.IsSharedSizeScope="True"
                                      KeyboardNavigation.TabIndex="1"
                                      Panel.ZIndex="1"/>
                            <ContentPresenter x:Name="PART_SelectedContentHost"
                                              Grid.Column="0"
                                              Grid.Row="1"
                                              ContentSource="SelectedContent"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              KeyboardNavigation.DirectionalNavigation="Contained"
                                              KeyboardNavigation.TabIndex="2"
                                              KeyboardNavigation.TabNavigation="Local"/>
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="FirstRowDefinition" Property="Height" Value="*"/>
                            <Setter TargetName="SecondRowDefinition" Property="Height" Value="Auto"/>
                            <Setter TargetName="Border" Property="Grid.Row" Value="1"/>
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="1"/>
                            <Setter TargetName="PART_SelectedContentHost" Property="Grid.Row" Value="0"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="FirstColumnDefinition" Property="Width" Value="Auto"/>
                            <Setter TargetName="SecondColumnDefinition" Property="Width" Value="*"/>
                            <Setter TargetName="FirstRowDefinition" Property="Height" Value="*"/>
                            <Setter TargetName="SecondRowDefinition" Property="Height" Value="0"/>
                            <Setter TargetName="Border" Property="Grid.Column" Value="0"/>
                            <Setter TargetName="HeaderPanel" Property="Grid.Column" Value="0"/>
                            <Setter TargetName="PART_SelectedContentHost" Property="Grid.Column" Value="1"/>
                            <Setter TargetName="Border" Property="Grid.Row" Value="0"/>
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="0"/>
                            <Setter TargetName="PART_SelectedContentHost" Property="Grid.Row" Value="0"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="FirstColumnDefinition" Property="Width" Value="*"/>
                            <Setter TargetName="SecondColumnDefinition" Property="Width" Value="Auto"/>
                            <Setter TargetName="FirstRowDefinition" Property="Height" Value="*"/>
                            <Setter TargetName="SecondRowDefinition" Property="Height" Value="0"/>
                            <Setter TargetName="Border" Property="Grid.Column" Value="1"/>
                            <Setter TargetName="HeaderPanel" Property="Grid.Column" Value="1"/>
                            <Setter TargetName="PART_SelectedContentHost" Property="Grid.Column" Value="0"/>
                            <Setter TargetName="Border" Property="Grid.Row" Value="0"/>
                            <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="0"/>
                            <Setter TargetName="PART_SelectedContentHost" Property="Grid.Row" Value="0"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>
            <Trigger Property="TabStripPlacement" Value="Top">
                <Setter Property="Root:Parameters.TabControlIndicatorThickness">
                    <Setter.Value>
                        <Thickness Left="0"
                                   Top="0"
                                   Right="0"
                                   Bottom="{x:Static Root:Parameters.BoldStrokeThickness}"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Bottom">
                <Setter Property="Root:Parameters.TabControlIndicatorThickness">
                    <Setter.Value>
                        <Thickness Left="0"
                                   Top="{x:Static Root:Parameters.BoldStrokeThickness}"
                                   Right="0"
                                   Bottom="0"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Left">
                <Setter Property="Root:Parameters.TabControlIndicatorThickness">
                    <Setter.Value>
                        <Thickness Left="0"
                                   Top="0"
                                   Right="{x:Static Root:Parameters.BoldStrokeThickness}"
                                   Bottom="0"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Right">
                <Setter Property="Root:Parameters.TabControlIndicatorThickness">
                    <Setter.Value>
                        <Thickness Left="{x:Static Root:Parameters.BoldStrokeThickness}"
                                   Top="0"
                                   Right="0"
                                   Bottom="0"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="BorderBrush" Value="{StaticResource Disabled}"/>
                <Setter Property="Foreground" Value="{StaticResource Disabled}"/>
            </Trigger>            
        </Style.Triggers>
        
    </Style>

</ResourceDictionary>